import http from '@/utils/http'

const BASE_URL = '/testing/uiCaseStep'

export interface UiCaseStepResp {
  id: string
  projectId: string
  caseId: string
  num: string
  name: string
  operationType: string
  locationType: string
  locationExpress: string
  elementWait: string
  targetLocationType: string
  targetLocationExpress: string
  targetElementWait: string
  value: string
  expectKey: string
  expectValue: string
  description: string
  isContinue: string
  isScreenshot: string
  stepType: string
  referStepId: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface UiCaseStepDetailResp {
  id: string
  projectId: string
  caseId: string
  num: string
  name: string
  operationType: string
  locationType: string
  locationExpress: string
  elementWait: string
  targetLocationType: string
  targetLocationExpress: string
  targetElementWait: string
  value: string
  expectKey: string
  expectValue: string
  description: string
  isContinue: string
  isScreenshot: string
  stepType: string
  referStepId: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface UiCaseStepQuery {
  version: string
  createdBy: string
  sort: Array<string>
}
export interface UiCaseStepPageQuery extends UiCaseStepQuery, PageQuery {}

/** @desc 查询UI用例步骤列表 */
export function listUiCaseStep(query: UiCaseStepPageQuery) {
  return http.get<PageRes<UiCaseStepResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询UI用例步骤详情 */
export function getUiCaseStep(id: string) {
  return http.get<UiCaseStepDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增UI用例步骤 */
export function addUiCaseStep(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改UI用例步骤 */
export function updateUiCaseStep(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除UI用例步骤 */
export function deleteUiCaseStep(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出UI用例步骤 */
export function exportUiCaseStep(query: UiCaseStepQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}
